﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETL.Common.Logging;
using ETL.DataAccess;

namespace ETL.Business.Handlers.ProjectLogHandler
{
    public class AddNewProjectLog
    {
        private readonly ProjectLogRepository _projectLogRepository;

        public AddNewProjectLog(ProjectLogRepository projectLogRepository)
        {
            _projectLogRepository = projectLogRepository;
        }
        public AddNewProjectLog()
        {
            _projectLogRepository = new ProjectLogRepository();
        }
        public virtual void Execute(short? projectId,short? categoryId, short? taskId, string userId, string detail)
        {
            try
            {
                if (projectId.HasValue && categoryId.HasValue && taskId.HasValue)
                {
                    // get latest from DB  DateTime dt, float hours
                    _projectLogRepository.AddProjectLog(userId, projectId, categoryId, taskId, detail);
                }

            }
            catch (Exception ex)
            {
                LogService.Service.Debug(ex);
            }
        }

    }
}
